export type { CourseModel, ExperimentModel } from './types'

import { fetcher } from '../fetcher'
import type {
  GetCourseDetailData,
  GetCourseExperimentsData,
  SearchCourseData,
  SearchCoursePayload
} from './types'

export const KeyApiSearchCourse = ['KeyApiSearchCourse'] as const
export function ApiSearchCourse(query: SearchCoursePayload) {
  return fetcher<SearchCourseData>('/courses', { query })
}

export function KeyApiGetCourseExperiments(id: number) {
  return ['get', 'courses', id, 'experiments'] as const
}
export function ApiGetCourseExperiments(courseID: number) {
  return fetcher<GetCourseExperimentsData>(`/courses/${courseID}/experiments`)
}

export function KeyApiGetCourseDetail(id: number) {
  return ['get', 'courses', id] as const
}
export function ApiGetCourseDetail(id: number) {
  return fetcher<GetCourseDetailData>(`/courses/${id}`)
}
